package top.tangyh.lamp.care.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import top.tangyh.basic.annotation.log.WebLog;
import top.tangyh.basic.base.R;
import top.tangyh.basic.interfaces.echo.EchoService;
import top.tangyh.basic.base.controller.SuperController;
import top.tangyh.lamp.care.entity.*;
import top.tangyh.lamp.care.service.BHl7YzService;
import top.tangyh.lamp.care.service.BHl7YzYaoPlanService;
import top.tangyh.lamp.care.vo.query.*;
import top.tangyh.lamp.care.vo.result.LisResultOutVO;
import top.tangyh.lamp.care.vo.result.OperaInfoOutVO;
import top.tangyh.lamp.care.vo.save.BHl7YzSaveVO;
import top.tangyh.lamp.care.vo.save.OperaInfoInVO;
import top.tangyh.lamp.care.vo.update.BHl7YzUpdateVO;
import top.tangyh.lamp.care.vo.result.BHl7YzResultVO;
import top.tangyh.lamp.system.vo.result.application.ApplicationResourceResultVO;

import javax.validation.Valid;
import java.util.List;

import static top.tangyh.basic.base.R.success;
import static top.tangyh.lamp.common.constant.SwaggerConstants.DATA_TYPE_STRING;

/**
 * <p>
 * 前端控制器
 * 医嘱表包含用药，检验，检查
 * </p>
 *
 * @author zqb
 * @date 2024-07-15 10:48:09
 * @create [2024-07-15 10:48:09] [zqb] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/yz")
@Tag(name = "HL7:医嘱主接口信息  手术医嘱/患者信息")
public class BHl7YzController {
    //    extends SuperController<BHl7YzService, Long, BHl7Yz
//            , BHl7YzSaveVO, BHl7YzUpdateVO, BHl7YzPageQuery, BHl7YzResultVO>
//    private final EchoService echoService;
//    @Override
//    public EchoService getEchoService() {
//        return echoService;
//    }
    private final BHl7YzService bHl7YzService;

    private final BHl7YzYaoPlanService bHl7YzYaoPlanService;

    @Operation(summary = ("医嘱查询接口"))
    @GetMapping("/list")
    public R<List<BHl7Yz>> selectYzListByQuery(YzQueryVO queryVO) {
        List<BHl7Yz> result = bHl7YzService.selectYzListByQuery(queryVO);
        return R.success(result);
    }


    @Operation(summary = ("检验申请 数据"))
    @GetMapping("/bar/list")
    public R<List<BHl7LisBar>> selectYzBarListByQuery(ListBarQueryVO listBarQueryVO) {
        List<BHl7LisBar> result = bHl7YzService.selectLisBarByQuery(listBarQueryVO);
        return R.success(result);
    }

    @Operation(summary = ("执行用药查询接口"))
    @GetMapping("/yao/exe")
    public R<List<BHl7YzYaoExe>> selectYaoExeListByQuery(YzYaoExeQueryVO queryVO) {
        List<BHl7YzYaoExe> result = bHl7YzService.selectYaoExeListByQuery(queryVO);
        return R.success(result);
    }

    @Operation(summary = ("用药计划和明细查询接口"))
    @GetMapping("/yao/plan")
    public R<List<BHl7YzYaoPlan>> selectPlanByQuery(YzYaoPlanQueryVO queryVO) {
        List<BHl7YzYaoPlan> result = bHl7YzYaoPlanService.selectPlanByQuery(queryVO);
        return R.success(result);
    }

    @Operation(summary = ("检验结果查询接口"))
    @GetMapping("/lis/result")
    public R<List<BHl7YzLisResult>> selectLisResultByQuery(YzListResultQueryVO queryVO) {
        List<BHl7YzLisResult> result = bHl7YzService.selectLisResultByQuery(queryVO);
        return R.success(result);
    }

    @Operation(summary = ("检查结果查询接口"))
    @GetMapping("/pacs/result")
    public R<List<BHl7YzPacsResult>> selectPacsResultByQuery(YzPacsResultQueryVO queryVO) {
        List<BHl7YzPacsResult> result = bHl7YzService.selectPacsResultByQuery(queryVO);
        return R.success(result);
    }

    @Operation(summary = ("检验项目明细查询接口"))
    @PostMapping("/lis/result/detail")
    public R<List<LisResultOutVO>> selectLisDetailByQuery(@RequestBody @Valid LisDetailQueryVO queryVO) {
        List<LisResultOutVO> result = bHl7YzService.selectListDetailByQuery(queryVO);
        return R.success(result);
    }


    @Parameters({
            @Parameter(name = "hospitalNumber", description = "住院号", schema = @Schema(type = DATA_TYPE_STRING), in = ParameterIn.QUERY),
    })
    @Operation(summary = "查询患者的手术列表")
    @GetMapping("/opera/list")
    @WebLog(value = "查询患者的手术列表")
    public R<List<OperaInfoOutVO>> listOperaInfo(@RequestParam String hospitalNumber) {
        return success(bHl7YzService.listOperaInfo(hospitalNumber));
    }


    @Operation(summary = "添加手术")
    @PostMapping("/opera/add")
    public R add(@RequestBody OperaInfoInVO infoInVO) {
        bHl7YzService.addOperaInfo(infoInVO);
        return success();
    }

    @Operation(summary = "修改手术")
    @PutMapping("/opera/update")
    public R update(@RequestBody OperaInfoInVO infoInVO) {
        bHl7YzService.updateOperaInfo(infoInVO);
        return success();
    }

    @Operation(summary = "删除手术")
    @DeleteMapping("/opera/delete")
    public R delete(@RequestParam Long id) {
        bHl7YzService.deleteOperaInfo(id);
        return success();
    }


}


